%%%Run all the counterfactuals together


Run_code;
Run_code_onlytrade;
Run_code_onlyIPR;
Run_code_domesticIPR;
Run_code_anticipated;
Run_code_anticipatedoptimal;
Run_code_gradual;
Run_code_myopic;
Run_code_Chinadeviates5periods;
Run_code_Chinadeviates5periodsretal;
Run_code_uncooperative;

load Baseline;
load OnlyTrade;
load OnlyIPR;
load DomesticIPR;
load Anticipated;
load Anticipatedoptimal;
load Gradual;
load Myopic;
load Chinadeviates;
load Chinadeviatesretal;
load Uncooperative;


save Results_Analysis.mat


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%Results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
load Results_Analysis.mat


%%Sensitivity
growth=[gc1_counterf(50) gc1_counterf_onlytrade(50) gc1_counterf_onlyIPR(50) gc1_counterf_domesticIPR(50)  gc1_counterf_myopic(50) gc1_counterf_Chinadeviates5periods(50) gc1_counterf_gradual(50) gc1_counterf_anticipated(50) gc1_counterf_anticipatedoptimal(50)]';  

welfare = [GFT1' GFT3'; GFT1_onlytrade' GFT3_onlytrade'; GFT1_onlyIPR' GFT3_onlyIPR'; GFT1_domesticIPR' GFT3_domesticIPR'; GFT1_myopic' GFT3_myopic'; GFT1_Chinadeviates5periods' GFT3_Chinadeviates5periods'; ; GFT1_gradual' GFT3_gradual'; ; GFT1_anticipated' GFT3_anticipated'; ; GFT1_anticipatedoptimal' GFT3_anticipatedoptimal'];

Results = [welfare growth];



%%%%%%%%%%%%%%%%%%%%Baseline%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(1)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
%legend('Baseline','Only trade','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'US_baseline.pdf', 'Append', true);

%%%%China
figure(2)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
%legend('Baseline','Only trade','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'China_baseline.pdf', 'Append', true);







%%%%%%%%%%%%%%%%%%%%Baseline SR%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(1)
hold on 
graph_baseline=plot([C1counterf(1:15).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_zeros=plot(zeros(15,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
%legend('Baseline','Only trade','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21])
xticklabels({'-10','-5','0','5'})

hold off

exportgraphics(gcf,'US_baselineSR.pdf', 'Append', true);

%%%%China
figure(2)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:10).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_zeros=plot(zeros(20,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
%legend('Baseline','Only trade','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21])
xticklabels({'-10','-5','0','5','10'})

hold off

exportgraphics(gcf,'China_baselineSR.pdf', 'Append', true);







%%%%%%%%%%%%%%%%%%%%only trade%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(3)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C1counterf_onlytrade(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only trade','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'US_onlytrade.pdf', 'Append', true);



%%%%China
figure(4)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C3counterf_onlytrade(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only trade','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'China_onlytrade.pdf', 'Append', true);







%%%%%%%%%%%%%%%%%%%%Uncooperative%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(3)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C1counterf_uncooperative(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_onlyIPR=plot([zeros(1,10) C1counterf_myopic(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '-.','color', 'b');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Uncooperative','Shortsighted','Initial BGP', 'Location' , 'southoutside', 'NumColumns', 2);
%legend('Baseline','NE','Myopic','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'US_NE2.pdf', 'Append', true);



%%%%China
figure(4)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C3counterf_uncooperative(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_onlyIPR=plot([zeros(1,10) C3counterf_myopic(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '-.','color', 'b');

graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Uncooperative','Shortsighted','Initial BGP', 'Location','southoutside', 'NumColumns', 2);
%legend('Baseline','NE','Myopic','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'China_NE.pdf', 'Append', true);






%%%%%%%%%%%%%%%%%%%%only IPR%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(5)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlyIPR=plot([zeros(1,10) C1counterf_onlyIPR(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only IPR','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'US_onlyIPR.pdf', 'Append', true);



%%%%China
figure(6)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlyIPR=plot([zeros(1,10) C3counterf_onlyIPR(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only IPR','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'China_onlyIPR.pdf', 'Append', true);




%%%%%%%%%%%%%%%%%%%%Domestic IPR%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(7)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_domesticIPR=plot([zeros(1,10) C1counterf_domesticIPR(1:50).*100])
set(graph_domesticIPR,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Domestic IPR','Initial BGP', 'Location', 'southoutside', 'NumColumns', 2);
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'US_domesticIPR.pdf', 'Append', true);



%%%%China
figure(8)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_domesticIPR=plot([zeros(1,10) C3counterf_domesticIPR(1:50).*100])
set(graph_domesticIPR,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Domestic IPR','Initial BGP','Location', 'southoutside', 'NumColumns', 2);
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off
exportgraphics(gcf,'China_domesticIPR.pdf', 'Append', true);


%%%%%%%%%%%%%%%%%%%%Anticipated vs unanticipated%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(9)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_anticipated=plot([zeros(1,10) C1counterf_anticipated(1:50).*100])
set(graph_anticipated,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Anticipated','Initial BGP')
%legend('Baseline','Anticipated','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off
exportgraphics(gcf,'US_anticipated.pdf', 'Append', true);



%%%%China
figure(10)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_anticipated=plot([zeros(1,10) C3counterf_anticipated(1:50).*100])
set(graph_anticipated,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Anticipated','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'China_anticipated.pdf', 'Append', true);


%%%%%%%%%%%%%%%%%%%%Anticipated (optimal) vs unanticipated%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(11)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_anticipated=plot([zeros(1,10) C1counterf_anticipatedoptimal(1:50).*100])
set(graph_anticipated,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_gradual=plot([zeros(1,10) C1counterf_gradual(1:50).*100])
set(graph_gradual,'LineWidth',2, 'LineStyle', '-.','color', 'k');

graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Anticipated','Gradual','Initial BGP', 'Location' , 'southoutside', 'NumColumns', 2);
%legend('Baseline','Anticipated','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'US_anticipatedopt.pdf', 'Append', true);


%%%%China
figure(12)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_anticipated=plot([zeros(1,10) C3counterf_anticipatedoptimal(1:50).*100])
set(graph_anticipated,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_gradual=plot([zeros(1,10) C3counterf_gradual(1:50).*100])
set(graph_gradual,'LineWidth',2, 'LineStyle', '-.','color', 'k');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Anticipated','Gradual','Initial BGP', 'Location' , 'southoutside', 'NumColumns', 2);
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'China_anticipatedopt.pdf', 'Append', true);



%%%%%%%%%%%%%%%%%%%%Baseline vs gradual%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(13)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_anticipated=plot([zeros(1,10) C1counterf_gradual(1:50).*100])
set(graph_anticipated,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Gradual','Initial BGP')
%legend('Baseline','Anticipated','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'US_gradual.pdf', 'Append', true);


%%%%China
figure(14)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_anticipated=plot([zeros(1,10) C3counterf_gradual(1:50).*100])
set(graph_anticipated,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Gradual','Initial BGP')
%legend('Baseline','Gradual','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off


exportgraphics(gcf,'China_gradual.pdf', 'Append', true);




%%%%%%%%%%%%%%%%%%%%Baseline vs China deviates%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(15)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_Chinadeviates=plot([zeros(1,10) C1counterf_Chinadeviates5periods(1:50).*100])
set(graph_Chinadeviates,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','China deviates','Initial BGP')
%legend('Baseline','Anticipated','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'US_Chinadeviates.pdf', 'Append', true);


%%%%China
figure(16)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_Chinadeviates=plot([zeros(1,10) C3counterf_Chinadeviates5periods(1:50).*100])
set(graph_Chinadeviates,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','China deviates','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off


exportgraphics(gcf,'China_Chinadeviates.pdf', 'Append', true);







%%%%%%%%%%%%%%%%%%%%Mechanism%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(17)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C1counterf_onlytrade(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_onlyIPR=plot([zeros(1,10) C1counterf_onlyIPR(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '-.','color', 'b');

graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only trade','Only IPR', 'Initial BGP', 'Location' , 'southoutside', 'NumColumns', 2);
%legend('Baseline','Anticipated','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'Mechanism_US.pdf', 'Append', false);


%%%%China
figure(18)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C3counterf_onlytrade(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_onlyIPR=plot([zeros(1,10) C3counterf_onlyIPR(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '-.','color', 'b');

graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only trade','Only IPR', 'Initial BGP', 'Location' , 'southoutside', 'NumColumns', 2);

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off


exportgraphics(gcf,'Mechanism_China.pdf', 'Append', false);





%%%%%%%%%%%%%%%%%%%%Baseline vs myopic%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(19)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_Chinadeviates=plot([zeros(1,10) C1counterf_myopic(1:50).*100])
set(graph_Chinadeviates,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Myopic','Initial BGP')
%legend('Baseline','Anticipated','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf, 'US_myopic.pdf', 'ContentType', 'vector', 'Resolution', 300);


%%%%China
figure(20)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_Chinadeviates=plot([zeros(1,10) C3counterf_myopic(1:50).*100])
set(graph_Chinadeviates,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Myopic','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off


exportgraphics(gcf,'China_myopic.pdf', 'Append', true);






%%%%%%%%%%%%%%%%%%%%China deviates%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure(21)
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C1counterf_Chinadeviates5periods(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_onlyIPR=plot([zeros(1,10) C1counterf_Chinadeviates5periodsretal(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '-.','color', 'b');

graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','China deviates','China deviates (retaliation)', 'Initial BGP', 'Location' , 'southoutside', 'NumColumns', 2);
%legend('Baseline','Anticipated','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off

exportgraphics(gcf,'Chinadeviatesretal_US.pdf', 'Append', false);


%%%%China
figure(22)
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C3counterf_Chinadeviates5periods(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_onlyIPR=plot([zeros(1,10) C3counterf_Chinadeviates5periodsretal(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '-.','color', 'b');

graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','China deviates','China deviates (retaliation)', 'Initial BGP', 'Location' , 'southoutside', 'NumColumns', 2);

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off


exportgraphics(gcf,'Chinadeviatesretal_China.pdf', 'Append', false);




